home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / gnu / flex / flexb237.zoo / flex.skel < prev    next >
Text File  |  1991-04-10  |  20KB  |  850 lines

  1. /* A lexical scanner generated by flex */
  2.  
  3. /* scanner skeleton version:
  4.  * $Header: /usr/fsys/odin/a/vern/flex/RCS/flex.skel,v 2.16 90/08/03 14:09:36 vern Exp $
  5.  */
  6.  
  7. #define FLEX_SCANNER
  8.  
  9. #include <stdio.h>
  10.  
  11.  
  12. /* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
  13. #ifdef c_plusplus
  14. #ifndef __cplusplus
  15. #define __cplusplus
  16. #endif
  17. #endif
  18.  
  19.  
  20. #ifdef __cplusplus
  21.  
  22. #include <stdlib.h>
  23. #include <osfcn.h>
  24.  
  25. /* use prototypes in function declarations */
  26. #define YY_USE_PROTOS
  27.  
  28. /* the "const" storage-class-modifier is valid */
  29. #define YY_USE_CONST
  30.  
  31. #else    /* ! __cplusplus */
  32.  
  33. #ifdef __STDC__
  34.  
  35. #ifdef __GNUC__
  36. #include <stddef.h>
  37. void *malloc( size_t );
  38. void free( void* );
  39. #else
  40. #include <stdlib.h>
  41. #endif    /* __GNUC__ */
  42.  
  43. #define YY_USE_PROTOS
  44. #define YY_USE_CONST
  45.  
  46. #endif    /* __STDC__ */
  47. #endif    /* ! __cplusplus */
  48.  
  49.  
  50. #ifdef __TURBOC__
  51. #define YY_USE_CONST
  52. #endif
  53.  
  54. #ifdef atarist
  55. #include <stdlib.h>
  56. #include <string.h>
  57. #include <memory.h>
  58. int _yyread(int fd, char *buf, int size);
  59.  
  60. #define YY_INPUT(buf,result,max_size) \
  61.     if ( (result = _yyread( fileno(yyin), (char *) buf, max_size )) < 0 ) \
  62.         YY_FATAL_ERROR( "read() in flex scanner failed" );
  63. #endif
  64.  
  65.  
  66. #ifndef YY_USE_CONST
  67. #define const
  68. #endif
  69.  
  70.  
  71. #ifdef YY_USE_PROTOS
  72. #define YY_PROTO(proto) proto
  73. #else
  74. #define YY_PROTO(proto) ()
  75. /* we can't get here if it's an ANSI C compiler, or a C++ compiler,
  76.  * so it's got to be a K&R compiler, and therefore there's no standard
  77.  * place from which to include these definitions
  78.  */
  79. char *malloc();
  80. int free();
  81. int read();
  82. #endif
  83.  
  84.  
  85. /* amount of stuff to slurp up with each read */
  86. #ifndef YY_READ_BUF_SIZE
  87. #define YY_READ_BUF_SIZE 8192
  88. #endif
  89.  
  90. /* returned upon end-of-file */
  91. #define YY_END_TOK 0
  92.  
  93. /* copy whatever the last rule matched to the standard output */
  94.  
  95. /* cast to (char *) is because for 8-bit chars, yytext is (unsigned char *) */
  96. /* this used to be an fputs(), but since the string might contain NUL's,
  97.  * we now use fwrite()
  98.  */
  99. #define ECHO (void) fwrite( (char *) yytext, yyleng, 1, yyout )
  100.  
  101. /* gets input and stuffs it into "buf".  number of characters read, or YY_NULL,
  102.  * is returned in "result".
  103.  */
  104. #ifndef YY_INPUT
  105. #define YY_INPUT(buf,result,max_size) \
  106.     if ( (result = read( fileno(yyin), (char *) buf, max_size )) < 0 ) \
  107.         YY_FATAL_ERROR( "read() in flex scanner failed" );
  108. #endif
  109. #define YY_NULL 0
  110.  
  111. /* no semi-colon after return; correct usage is to write "yyterminate();" -
  112.  * we don't want an extra ';' after the "return" because that will cause
  113.  * some compilers to complain about unreachable statements.
  114.  */
  115. #define yyterminate() return ( YY_NULL )
  116.  
  117. /* report a fatal error */
  118.  
  119. /* The funky do-while is used to turn this macro definition into
  120.  * a single C statement (which needs a semi-colon terminator).
  121.  * This avoids problems with code like:
  122.  *
  123.  *     if ( something_happens )
  124.  *        YY_FATAL_ERROR( "oops, the something happened" );
  125.  *    else
  126.  *        everything_okay();
  127.  *
  128.  * Prior to using the do-while the compiler would get upset at the
  129.  * "else" because it interpreted the "if" statement as being all
  130.  * done when it reached the ';' after the YY_FATAL_ERROR() call.
  131.  */
  132.  
  133. #define YY_FATAL_ERROR(msg) \
  134.     do \
  135.         { \
  136.         (void) fputs( msg, stderr ); \
  137.         (void) putc( '\n', stderr ); \
  138.         exit( 1 ); \
  139.         } \
  140.     while ( 0 )
  141.  
  142. /* default yywrap function - always treat EOF as an EOF */
  143. #define yywrap() 1
  144.  
  145. /* enter a start condition.  This macro really ought to take a parameter,
  146.  * but we do it the disgusting crufty way forced on us by the ()-less
  147.  * definition of BEGIN
  148.  */
  149. #define BEGIN yy_start = 1 + 2 *
  150.  
  151. /* action number for EOF rule of a given start state */
  152. #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
  153.  
  154. /* special action meaning "start processing a new file" */
  155. #define YY_NEW_FILE \
  156.     do \
  157.         { \
  158.         yy_init_buffer( yy_current_buffer, yyin ); \
  159.         yy_load_buffer_state(); \
  160.         } \
  161.     while ( 0 )
  162.  
  163. /* default declaration of generated scanner - a define so the user can
  164.  * easily add parameters
  165.  */
  166. #define YY_DECL int yylex YY_PROTO(( void )) 
  167.  
  168. /* code executed at the end of each rule */
  169. #define YY_BREAK break;
  170.  
  171. #define YY_END_OF_BUFFER_CHAR 0
  172.  
  173. #ifndef YY_BUF_SIZE
  174. #define YY_BUF_SIZE (YY_READ_BUF_SIZE * 2) /* size of default input buffer */
  175. #endif
  176.  
  177. typedef struct yy_buffer_state *YY_BUFFER_STATE;
  178.  
  179. %% section 1 definitions go here
  180.  
  181. /* done after the current pattern has been matched and before the
  182.  * corresponding action - sets up yytext
  183.  */
  184. #define YY_DO_BEFORE_ACTION \
  185.     yytext = yy_bp; \
  186. %% code to fiddle yytext and yyleng for yymore() goes here
  187.     yy_hold_char = *yy_cp; \
  188.     *yy_cp = '\0'; \
  189.     yy_c_buf_p = yy_cp;
  190.  
  191. #define EOB_ACT_CONTINUE_SCAN 0
  192. #define EOB_ACT_END_OF_FILE 1
  193. #define EOB_ACT_LAST_MATCH 2
  194.  
  195. /* return all but the first 'n' matched characters back to the input stream */
  196. #define yyless(n) \
  197.     do \
  198.         { \
  199.         /* undo effects of setting up yytext */ \
  200.         *yy_cp = yy_hold_char; \
  201.         yy_c_buf_p = yy_cp = yy_bp + n; \
  202.         YY_DO_BEFORE_ACTION; /* set up yytext again */ \
  203.         } \
  204.     while ( 0 )
  205.  
  206. #define unput(c) yyunput( c, yytext )
  207.  
  208.  
  209. struct yy_buffer_state
  210.     {
  211.     FILE *yy_input_file;
  212.  
  213.     YY_CHAR *yy_ch_buf;        /* input buffer */
  214.     YY_CHAR *yy_buf_pos;    /* current position in input buffer */
  215.  
  216.     /* size of input buffer in bytes, not including room for EOB characters*/
  217.     int yy_buf_size;    
  218.  
  219.     /* number of characters read into yy_ch_buf, not including EOB characters */
  220.     int yy_n_chars;
  221.  
  222.     int yy_eof_status;        /* whether we've seen an EOF on this buffer */
  223. #define EOF_NOT_SEEN 0
  224.     /* "pending" happens when the EOF has been seen but there's still
  225.      * some text process
  226.      */
  227. #define EOF_PENDING 1
  228. #define EOF_DONE 2
  229.     };
  230.  
  231. static YY_BUFFER_STATE yy_current_buffer;
  232.  
  233. /* we provide macros for accessing buffer states in case in the
  234.  * future we want to put the buffer states in a more general
  235.  * "scanner state"
  236.  */
  237. #define YY_CURRENT_BUFFER yy_current_buffer
  238.  
  239.  
  240. /* yy_hold_char holds the character lost when yytext is formed */
  241. static YY_CHAR yy_hold_char;
  242.  
  243. static int yy_n_chars;        /* number of characters read into yy_ch_buf */
  244.  
  245.  
  246.  
  247. #ifndef YY_USER_ACTION
  248. #define YY_USER_ACTION
  249. #endif
  250.  
  251. #ifndef YY_USER_INIT
  252. #define YY_USER_INIT
  253. #endif
  254.  
  255. extern YY_CHAR *yytext;
  256. extern int yyleng;
  257. extern FILE *yyin, *yyout;
  258.  
  259. YY_CHAR *yytext;
  260. int yyleng;
  261.  
  262. FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;
  263.  
  264. %% data tables for the DFA go here
  265.  
  266. /* these variables are all declared out here so that section 3 code can
  267.  * manipulate them
  268.  */
  269. /* points to current character in buffer */
  270. static YY_CHAR *yy_c_buf_p = (YY_CHAR *) 0;
  271. static int yy_init = 1;        /* whether we need to initialize */
  272. static int yy_start = 0;    /* start state number */
  273.  
  274. /* flag which is used to allow yywrap()'s to do buffer switches
  275.  * instead of setting up a fresh yyin.  A bit of a hack ...
  276.  */
  277. static int yy_did_buffer_switch_on_eof;
  278.  
  279. static yy_state_type yy_get_previous_state YY_PROTO(( void ));
  280. static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state ));
  281. static int yy_get_next_buffer YY_PROTO(( void ));
  282. static void yyunput YY_PROTO(( YY_CHAR c, YY_CHAR *buf_ptr ));
  283. void yyrestart YY_PROTO(( FILE *input_file ));
  284. void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer ));
  285. void yy_load_buffer_state YY_PROTO(( void ));
  286. YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size ));
  287. void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b ));
  288. void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file ));
  289.  
  290. #define yy_new_buffer yy_create_buffer
  291.  
  292. #ifdef __cplusplus
  293. static int yyinput YY_PROTO(( void ));
  294. #else
  295. static int input YY_PROTO(( void ));
  296. #endif
  297.  
  298. YY_DECL
  299.     {
  300.     register yy_state_type yy_current_state;
  301.     register YY_CHAR *yy_cp, *yy_bp;
  302.     register int yy_act;
  303.  
  304. %% user's declarations go here
  305.  
  306.     if ( yy_init )
  307.     {
  308.     YY_USER_INIT;
  309.  
  310.     if ( ! yy_start )
  311.         yy_start = 1;    /* first start state */
  312.  
  313.     if ( ! yyin )
  314.         yyin = stdin;
  315.  
  316.     if ( ! yyout )
  317.         yyout = stdout;
  318.  
  319.     if ( yy_current_buffer )
  320.         yy_init_buffer( yy_current_buffer, yyin );
  321.     else
  322.         yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE );
  323.  
  324.     yy_load_buffer_state();
  325.  
  326.     yy_init = 0;
  327.     }
  328.  
  329.     while ( 1 )        /* loops until end-of-file is reached */
  330.     {
  331. %% yymore()-related code goes here
  332.     yy_cp = yy_c_buf_p;
  333.  
  334.     /* support of yytext */
  335.     *yy_cp = yy_hold_char;
  336.  
  337.     /* yy